from src.utils.config import STATIC_DIR
import jinja2

PROMPT_DIR = STATIC_DIR / "prompts"


"""Initialize Jinja2 environment with the prompt directory as template loader."""
loader = jinja2.FileSystemLoader(PROMPT_DIR)
jinja_env = jinja2.Environment(
    loader=loader, trim_blocks=True, lstrip_blocks=True, autoescape=True
)


def render_prompt(template_name, **kwargs) -> str:
    """
    Render a prompt template with the given context.

    Args:
        template_name: Name of the template file in the prompt directory
        kwargs: Context variables to pass to the template

    Returns:
        Rendered prompt text
    """
    template = jinja_env.get_template(template_name)
    return template.render(**kwargs)
